#pragma once

#include <stdlib.h>

#ifdef _DEBUG
#include <stdio.h>
#endif

/******************************************************************************/
/*                                                                            */
/*   PFObject class for Penguin Framework 0.1 (first draft)                   */
/*                                                                            */
/*   Object class description.                                                */
/*   ----------------------------------------------------------------------   */
/*   Objects are meaningless stubs which provide the base class for all       */
/*   Penguin Framework objects.                                               */
/*   To identify PFObjects, they have a class ID property which describes     */
/*   the class implementation to use for this object, as well as a size       */
/*   counter which is used for serialization. Each object has a unique        */
/*   object ID number generated randomly which is used for comparison.        */
/*                                                                            */
/******************************************************************************/

#define PF_CLASS_GENERIC	0x8000	/* Generic class flag: Class does not contain implementation */
#define PF_CLASS_OBJECT	    0x8001	/* Abstract object */

#define PF_RESULT_SUCCESS	0x0000	/* Function success - no special event reported. */
#define PF_RESULT_FAIL	    0x8000	/* Function has a generic failure, query subsystem for fault reason */

#define PF_ERROR_NOT_IMPLEMENTED            0xFFFF
/* Attempt to call an uninplemented method. */

#define PF_ERROR_INVALID_PARAMETER          0x0008
/* A non-sane parameter was passed into a PF function. */

class PFObject
{
public:

	PFObject(void)
	{
		/* Use a simple random 32-bit integer for instance IDs */
		iInstanceID = rand();
		iClassID = PF_CLASS_OBJECT;
		dwSize = sizeof(class PFObject);
	}

	virtual int Create()
	{
		/**
		 * Initialize local variables in an object after instantiation.
		 */

#ifdef _DEBUG
		printf("PFObject: Object with instance %08x created successfully.\n", iInstanceID);
#endif

		/* Nothing to do - blissfully tell the world that we're OK */
		return PF_RESULT_SUCCESS;
	}

	unsigned long getClass() { return iClassID; }

	unsigned long getInstance() { return iInstanceID; }

	virtual int Destroy()
	{
		/**
		 *	Clean up local variables and state information.
		 */
#ifdef _DEBUG
		printf("PFObject: Object with instance %08x successfully destroyed.\n", iInstanceID);
#endif

		return PF_RESULT_SUCCESS;
	}

	virtual ~PFObject(void)
	{
	}

protected:
	unsigned long iClassID;
	unsigned long dwSize;
	unsigned long iInstanceID;
};
